package com.lhb.test.hadoop;

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.URI;

import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FSDataInputStream;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;

public class HadoopClient {
	
	public static void main(String[] args) throws Exception {
		FileSystem fs = FileSystem.get(new URI("hdfs://175.25.48.17:9000"), new Configuration(),"root");
		System.out.println(fs.getHomeDirectory());
		System.out.println(fs.getDefaultBlockSize());
		System.out.println(fs.getName());
		System.out.println(fs.getUsed());
		System.out.println(fs.getStatus());
		System.out.println(fs.getServerDefaults());
		Path path = new Path("/data/config/hdfs-site.xml");
		System.out.println(fs.exists(path));
		FSDataInputStream fsi = fs.open(path);
		BufferedReader bufReader = new BufferedReader(new InputStreamReader(fsi, "UTF-8"));
		String s =null;
		while((s=bufReader.readLine())!=null){
			System.out.println(s);
		}
		
	}
}
